<template>
	<view>
		<scroll-view scroll-y="true" :style="'height:'+scrollH+'px;'"
		@scrolltolower="loadmoreEvent">
			<block v-for="(item,index) in lawyerlist" :key="index">
				<selection-item :item="item" :index="index" @click="openDetail"></selection-item>
			</block>
			<load-more :loadmore="loadmore"></load-more>
		</scroll-view>
	</view>
</template>

<script>
	import selectionItem from '@/components/home/selection-item.vue';
	import loadMore from '@/components/common/load-more.vue';
	const lawyerdemo = [{
		username:"王倩倩",
		online:true,
		avatar:"https://img.xiaopiu.com/userImages/img6159694579f0.jpeg",
		priceDis:"￥15/分钟",
		serverScore:4.95,
		newstime:"02:05",
		location:"江苏 · 苏州",
		goodids:"1,2,3"
	},
	{
		username:"王倩文",
		online:true,
		avatar:"https://img.xiaopiu.com/userImages/img6159694579f0.jpeg",
		priceDis:"￥15/分钟",
		serverScore:4.95,
		newstime:"02:05",
		location:"江苏 · 苏州",
		goodids:"1,2,3"
	}];
	export default {
		components: {
			selectionItem,
			loadMore
		},
		data() {
			return {
				scrollH:500,
				lawyerlist:[],
				loadmore:"上拉加载更多",
			}
		},
		onLoad(e) {
			// 加载测试数据
			uni.getSystemInfo({
				success:res=>{
					this.scrollH = res.windowHeight;
				}
			});
			this.lawyerlist = [...lawyerdemo,...lawyerdemo];
		},
		methods: {
			// 上拉加载
			loadmoreEvent(){
				// 验证当前是否处于可加载状态
				if (this.loadmore !== '上拉加载更多') return;
				// 设置加载状态
				this.loadmore = '加载中...'
				// 模拟请求数据
				setTimeout(()=>{
					// 加载数据
					this.lawyerlist = [...this.lawyerlist,...this.lawyerlist]
					// 设置加载状态
					this.loadmore = '上拉加载更多'
				},2000)
			},
		}
	}
</script>

<style>

</style>
